package com.example.lotterysystem.common.exception;


import com.example.lotterysystem.common.errorcode.ErrorCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {
    //异常码
    private Integer code;

    //异常信息
    private String message;

    //Service 下的错误码可以设置 Service 下的异常信息
    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
}
